//
//  GoodsViewController.m
//  AppleCilent
//
//  Created by Nail Sharipov on 04/04/14.
//  Copyright (c) 2014 Nail Sharipov. All rights reserved.
//

#import "GoodsListViewController.h"
#import "GoodsTableView.h"
#import "CartManager.h"
#import "SceneManager.h"

@interface GoodsListViewController ()

@end

@implementation GoodsListViewController
{
    MenuDomain* menu;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad
{
   // [goodsTableView setMenu:menu];
    [super viewDidLoad];
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    int total = (int)[[CartManager getInstance] getTotalCost];
    [[self cartButton] setTitle:[NSString stringWithFormat:@"%i р.", total]forState:UIControlStateNormal];
}

- (void) setMenu: (MenuDomain*)menuDomain
{
    menu = menuDomain;
    [(GoodsTableView*)self.goodsView setMenu:menu];
    [self.menuName setText:[menu getName]];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)cartButtonPressed:(id)sender {
    [[SceneManager getInstance] openScene: @"Cart"];
}


- (IBAction)backButtonClick:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}


@end
